package com.ghn.cocknovel.ui.activity.more

import android.os.Build
import android.os.Bundle
import androidx.annotation.RequiresApi
import com.example.basemodel.base.BaseHeadVMActivity
import com.example.basemodel.base.DefaultHeadStyle
import com.ghn.cocknovel.R
import com.ghn.cocknovel.databinding.ActivityMoreBinding
import com.ghn.cocknovel.ui.activity.more.vm.MoreViewModel


class MoreActivity : BaseHeadVMActivity<MoreViewModel,ActivityMoreBinding, DefaultHeadStyle>() {


    override fun layoutId()=R.layout.activity_more

    @RequiresApi(Build.VERSION_CODES.M)
    override fun initView(savedInstanceState: Bundle?) {
        mHeadStyle.setTitleColor("更多统计", getColor(R.color.black))
        mHeadStyle.setTitleBackgroundColor(getColor(R.color.gray4))
        //在线时长
        mViewModel.getonlinetime()
        mViewModel.onlinetime.observe(this){
            mDatabind.moreTvToDayHour.text=it?.todayDuration.toString()
            mDatabind.moreTvOrderNum.text=it?.weekDuration.toString()
            mDatabind.moreTvReturnOrderNum.text=it?.monthDuration.toString()
        }
        //里程统计
        mViewModel.getcumulativenduartion()
        mViewModel.cumulativenduartion.observe(this){
            mDatabind.moreStatisticsTvToDayHour.text=it?.weekMileage?.toInt().toString()
            mDatabind.moreStatisticsTvOrderNum.text=it?.monthMileage?.toInt().toString()
        }
        //累计订单
        mViewModel.getcumulative()
        //more__statistics_tv_toDayHour
        mViewModel.cumulative.observe(this){
            //成单率/取消率
            mDatabind.moreSuccessTvToDayHour.text=it?.weekCompletionRate.toString()+"%"
            mDatabind.moreSuccessTvOrderNum.text=it?.monthCompletionRate.toString()+"%"
            mDatabind.moreChargebackTvToDayHour.text=it?.weekCancelRate.toString()+"%"
            mDatabind.moreChargebackTvOrderNum.text=it?.monthCancelRate.toString()+"%"
            //累计订单
            mDatabind.moreCumulativeTvToDayHour.text=it?.finishOrderNum.toString()
            mDatabind.moreCumulativeTvOrderNum.text=it?.weekFinishOrderNum.toString()
            mDatabind.moreCumulativeTvReturnOrderNum.text=it?.monthFinishOrderNum.toString()
            mDatabind.moreCumulativeTvRefundNum.text=it?.finishReturnOrderNum.toString()
            mDatabind.moreCumulativeTvWeekrefundNum.text=it?.weekFinishReturnOrderNum.toString()
            mDatabind.moreCumulativeTvMonthrefundNum.text=it?.monthFinishReturnOrderNum.toString()

        }
        //评分统计
        mViewModel.getscorestatistics()
        mViewModel.scorestatistics.observe(this){
            mDatabind.moreScoreTvToDayHour.text=it?.monthScores?.toInt().toString()
            mDatabind.moreScoreTvOrderNum.text=it?.monthScores?.toInt().toString()
        }

    }

    override fun createObserver() {

    }
}